package action;

import java.util.Collection;
import java.util.LinkedList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import manager.AgencyManager;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import dataType.AgencyData;
import dataType.ErrorData;
import exception.MyException;


public class ActionModificarAgencia extends Action {

	private static final long serialVersionUID = 1L;

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest req, HttpServletResponse resp) {
			Collection<AgencyData> colAgency = new LinkedList<AgencyData>();
			AgencyManager am = new AgencyManager();
			try {
				colAgency = am.getAgencies();
				req.setAttribute("colAgency", colAgency);
				return mapping.findForward("listar");		
			} catch (MyException e) {
				ErrorData error = new ErrorData(e.getMessage());
				req.setAttribute("errorData",error );
				return mapping.findForward("errorPage");		
			}					
	}
}
